/*
*	(*^。^*) TFrameWork License (*^。^*)
*/

/*
 *  Title :  
 *          
 *  Description :  
 *          
 *          
 *  Date : 
 *
 *  Author : DengPing
 *
 *  Modify : 
 */

using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

namespace TFrameWork.Module.ActionEditor
{
    /// <summary>
    /// 轨道数据
    /// </summary>
    [System.Serializable]
    public class TrackData : DataBase
    {
        /// <summary>
        /// 是否折叠轨道
        /// </summary>
        [HideInInspector] public bool isFlod = false;
        
        /// <summary>
        /// 使用TrackDataKeyAttribute 标记的Key
        /// </summary>
        public string trackDataKey;

        public List<TrackItemData> trackDatas = new List<TrackItemData>();

        #region Method

        public void AddData(TrackItemData data)
        {
            trackDatas.Add(data);
        }

        public TrackItemData RemoveData(int index)
        {
            TrackItemData data = trackDatas[index];
            trackDatas.RemoveAt(index);
            return data;
        }

        public void Sort()
        {
            foreach (var item in trackDatas)
            {
                item.Sort();
            }
        }

        public void Swap(int index1, int index2)
        {
            var track1 = trackDatas[index1];
            var track2 = trackDatas[index2];
            trackDatas[index1] = track2;
            trackDatas[index2] = track1;
        }

        public override object Clone()
        {
            var clone = base.Clone() as TrackData;
            clone.isFlod = isFlod;
            clone.trackDataKey = trackDataKey;

            clone.trackDatas = new List<TrackItemData>();
            for (int i = 0; i < trackDatas.Count; i++)
            {
                clone.trackDatas.Add(trackDatas[i].Clone() as TrackItemData);
            }

            return clone;
        }

        #endregion
    }
}
